<!--
 * @Description: 招聘-入职情况
 * @Author: rcc
 * @Date: 2024-08-13 17:06:53
 * @FilePath: /rc-recruitment/pages/office/employment/employment.vue
-->

<template>
	<view class="p-h24">
		<view class="m-t40 text-700-130">共 {{ list.length }} 条</view>

		<view class="flex m-t20 p-a20 bg-1 r-10" v-for="(item, key) in list" :key="key">
			<image class="square-108 r-10" :src="item.avatar" mode="aspectFill"></image>

			<view class="flex-1 flex-d-sb  m-l20">
				<view class="flex">
					<text class="text-700-130">{{ item.nickname }}</text>
					<text class="flex-1 p-h20 text-400-326">{{ item.gender == 1 ? '男' : '女' }} | {{ item.age }}岁</text>
					<text class="text-700-530">{{ item.title }}</text>
				</view>
				<view class="flex m-t20">
					<view class=" text-400-324" v-if="item.results == 1">已入职</view>
					<view class=" text-400-324" v-else-if="item.results == 0">未入职</view>
					<view class=" text-400-324" v-else>已离职</view>
				</view>
				<view class="foot">
					<view class="btn text-400-324" @click="handleAdd(item.id)">入职</view>
					<view class="btn text-400-324" @click="handleOut(item.id)">离职</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script lang="ts" setup>
import { ref } from 'vue';
const list: any = ref([])
//入职
async function handleAdd(id: number) {
	uni.showModal({
		title: '提示',
		content: '确定入职吗？',
		showCancel: true,
		cancelText: '取消',
		cancelColor: '#000000',
		confirmText: '确定',
		confirmColor: '#3CC51F',
		success: async (result) => {
			if (result.confirm) {
				const res = await uni.$u.post('/resume/entry', { id })
				if (res.code == 1) {
					uni.showToast({ title: "入职成功" })
					getList()
				} else {
					uni.showToast({ title: res.msg })
				}
			}
		}
	});
}
//离职
async function handleOut(id: number) {
	uni.showModal({
		title: '提示',
		content: '确定离职吗？',
		showCancel: true,
		cancelText: '取消',
		cancelColor: '#000000',
		confirmText: '确定',
		confirmColor: '#3CC51F',
		success: async (result) => {
			if (result.confirm) {
				const res = await uni.$u.post('/resume/resignation', { id })
				if (res.code == 1) {
					uni.showToast({ title: "操作成功" })
					getList()
				} else {
					uni.showToast({ title: res.msg })
				}
			}
		}
	})

}
//获取列表
async function getList() {
	const res = await uni.$u.get('/resume/entrylst')
	list.value = res.data
}
getList()
</script>

<style lang="scss" scoped>
page {
	background-color: $page-color-4;
}

.foot {
	padding: 20rpx 0 13rpx 0;
	border-top: 1rpx solid #EEEEEE;
	margin-top: 21rpx;
	display: flex;
	justify-content: end;

	.btn {
		width: 101rpx;
		height: 46rpx;
		line-height: 46rpx;
		text-align: center;
		background: #FFFFFF;
		border-radius: 4rpx 4rpx 4rpx 4rpx;
		border: 1rpx solid #BBBBBB;
	}

	.btn+.btn {
		margin-left: 10rpx;
	}
}

.tag {
	width: 128rpx;
	height: 46rpx;
	margin-right: 10rpx;
	line-height: 46rpx;
	text-align: center;
	border-radius: 4rpx;
	border: 1rpx solid #BBBBBB;
	opacity: 0.6;
}

.tag-el {
	opacity: 1;
}
</style>